package com.example.deviceinfo.di

import com.example.deviceinfo.data.network.NetworkConfig
import com.google.gson.Gson
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import okhttp3.OkHttpClient
import retrofit2.Retrofit
import javax.inject.Singleton


@Module
@InstallIn(SingletonComponent::class)
object NetworkModule {

    @Singleton
    @Provides
    fun provideGson() = NetworkConfig.provideGson()

    @Singleton
    @Provides
    fun provideOkHttpClient() = NetworkConfig.provideOkHttpClient()

    @Singleton
    @Provides
    fun provideRetrofit(gson: Gson, okHttpClient: OkHttpClient) =
        NetworkConfig.provideRetrofit(gson, okHttpClient)

    @Singleton
    @Provides
    fun provideDeviceApiService(retrofit: Retrofit) =
        NetworkConfig.provideDeviceApiService(retrofit)
}